/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package units;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import utils.Handle;

/**
 *
 * @author jamie
 */
public enum MonkeyType {

    A,
    M;

    public  List<Sample> getSamples(Handle h){
        List<Sample> samples = new ArrayList<Sample>();
        String sql = "select * from monkeys.sample and monkeyType='"+this.name()+"'";
        ResultSet rs = h.runSQLquery(sql);
        try {
            while (rs.next()) {
                Sample sample = new Sample();
                sample.setId(rs.getInt("id"));
                sample.setSampleName(rs.getString("sampleName"));
                sample.setMonkeyType(MonkeyType.valueOf(rs.getString("MonkeyType")));
                sample.setCellType(CellType.valueOf(rs.getString("cellType")));
                samples.add(sample);
            }
            rs.close();
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        return samples;
    }

}
